package com.season.seasonStudy.javase.j_021_io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.Reader;
import java.io.Writer;

public class Tasdasd {

	public static void main(String[] args) {
		BufferedReader br = null;
		BufferedWriter bw = null;
		try {
			Reader r = new FileReader("e:/wohenshuai/before.txt");
			Writer w = new FileWriter("e:/wohenshuai/now.txt");
			br = new BufferedReader(r);
			bw = new BufferedWriter(w);
			StringBuffer sb = new StringBuffer();
			String s = null;
			while ((s = br.readLine()) != null) {
				sb.append(s);
			}
			s = sb.toString();
			System.out.println("之前的：" + s);
			br.close();
			r.close();
			
			s=s.replace("{name}", "狗狗");
			s=s.replace("{type}", "仔仔");
			s=s.replace("{master}", "纪杰");
			bw.write(s);
			System.out.println("现在的：" + s);
			bw.close();
			w.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
